package com.atung.parking.enums;

import lombok.Getter;

/**
 * @author Administrator
 */
@Getter
public enum ParkingPackageState {
    ON_SHELF(201, "上架"),
    OFF_SHELF(202, "下架"),
    SOLD_OUT(203, "售罄");

    private final Integer code;
    private final String description;

    ParkingPackageState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 根据代码获取枚举常量
    public static ParkingPackageState fromCode(int code) {
        for (ParkingPackageState status : ParkingPackageState.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
    public static String getDescriptionByCode(Integer code) {
        for (ParkingPackageState state : ParkingPackageState.values()) {
            if (state.getCode().equals(code)) {
                return state.getDescription();
            }
        }
        return ""; // 如果没有找到匹配的code，返回null
    }
}
